<?php if (!defined('THINK_PATH')) exit();?><html>
<head>
    <meta charset="utf-8">
    <link href="/Public/css/Admin/Bootstrap/bootstrap.css" rel="stylesheet" />
    <link href="/Public/css/Admin/my.css" rel="stylesheet" />
    <link href="/Public/css/Admin/Validform/Validform.css" rel="stylesheet" />
    <link href="/Public/css/Admin/partner_n.css" rel="stylesheet" />
    <script language="JavaScript" src="/Public/js/Admin/jquery.1.11.3.min.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/my.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/Bootstrap/bootstrap.min.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/Bootstrap/bootstrap-treeview.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/Validform/Validform_v5.3.2_min.js"></script>
    <link href="/Public/css/Admin/flatpickr.min.css" rel="stylesheet" />
    <script src="/Public/js/Admin/flatpickr.js"></script>

    <script>
        $(function(){
            flatpickr(".start_time", {});
            flatpickr(".end_time", {});
            //flatpickr(".start_time", { enableTime:true,time_24hr:true}); // 具体时间
            //flatpickr(".end_time", {enableTime:true,time_24hr:true });
            // pop关闭
            $("#ent_pop_close2").click(function () {
                $("#ent_pop2").hide();
                $("#yindaobg2").hide();
            });
            $("#yindaobg2").click(function () {
                $("#ent_pop2").hide();
                $("#yindaobg2").hide();
            });
        })
    </script>
    <script type="text/javascript">
        $(function(){
            if( $(".registerform").html() )  {
                $(".registerform").Validform({
                    datatype:{
                        "money":function(gets,obj,curform,regxp){
                            re =  /^[0-9]+(.[0-9]{0,16})?$/;
                            if(re.test(gets)){
                                return true;
                            }else{
                                return false;
                            }
                        }

                    }
                });
            }
        });
    </script>

</head>
<body>
<nav class="navbar navbar-inverse">
    <div class="container" style="width: 100%;padding:0;">
        <div class="navbar-collapse collapse" style="width: 100%;padding:0;">
            <ul class="nav navbar-nav" style="width: 100%">
                <li <?php if(session('column_select') == ''): ?>class="active "<?php endif; ?>><a  style="padding-left:30px;padding-right:30px" href="<?php echo U('modules/columnSelect');?>">首页</a></li>
                <?php if(session('admin_modules') != ''): $_result=session('admin_modules')['modules'];if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><li
                            <?php if(session('column_select') != ''): if($val['id'] == session('column_select') ): ?>class="active"<?php endif; endif; ?>
                        >
                        <a style="padding-left:30px;padding-right:30px" href="<?php echo U('modules/columnSelect?id='.$val['id']);?>"  ><?php echo ($val["name"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; endif; ?>
                <li class="active" style="float:right"><a style="background-color:rgba(92, 173, 136, 0.92)" href="<?php echo U('index/quit');?>">退 出</a></li>
                <li class="active" style="float:right"><a style="background-color:rgba(92, 173, 136, 0.92)" href="<?php echo U('user/password');?>">修改密码</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="yindaobg popbg" id="yindaobg2"  style="z-index:999999;display: none">></div>
<div class="ent_pop" id="ent_pop2" style="z-index:9999999;display: none">
    <div class="ent_pop_title">
        <h5 id="open_title"></h5>
    </div>
    <div class="ent_pop_main" style="margin-bottom:0"></div>
    <div style="width:97%;text-align:right;margin-bottom:20px;" id="ent_pop_main_button">
        <input class="btn btn-primary btn-sm "  type="button" id="ent_submit" value="提交">&nbsp;&nbsp;
        <input class="btn btn-danger btn-sm "   id="ent_pop_close2" type="button" value="取消">
    </div>
</div>


<div class="container-fluid">
    <div class="row">
        <div class="col-md-2">
            <ul id="main-nav" class="nav nav-tabs nav-stacked" style="">
                <li class="active">
                    <a style="cursor:pointer"><i class="glyphicon glyphicon-th-large"></i>&nbsp;列表</a>
                </li>
                <?php if(session('modules_select') != ''): $_result=session('modules_select');if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><li>
                            <a href="#systemSetting<?php echo ($val["id"]); ?>" class="nav-header collapsed" data-toggle="collapse">
                                <i class="glyphicon glyphicon-cog"></i>&nbsp;<?php echo ($val["name"]); ?><span class="pull-right glyphicon glyphicon-chevron-down"></span>
                            </a>
                            <ul id="systemSetting<?php echo ($val["id"]); ?>" class="nav nav-list secondmenu collapse "  >
                                <?php if(is_array($val["list"])): $i = 0; $__LIST__ = $val["list"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val2): $mod = ($i % 2 );++$i;?><li><a id="color-eee<?php echo ($val["id"]); ?>-<?php echo ($val2["id"]); ?>" href="<?php echo U('Modules/select?id='.$val2['id']);?>"><i class="glyphicon  glyphicon glyphicon-chevron-right"></i>&nbsp;&nbsp;<?php echo ($val2["name"]); ?></a></li>
                                    <?php if($val2['url'] != ''): if($val2['id'] == session('select') ): ?><script>
                                                $(document).ready(function(){
                                                    $("#systemSetting<?php echo ($val["id"]); ?>").addClass("in");
                                                    $("#color-eee<?php echo ($val["id"]); ?>-<?php echo ($val2["id"]); ?>").addClass("color-eee");
                                                });
                                            </script><?php endif; endif; endforeach; endif; else: echo "" ;endif; ?>
                            </ul>
                        </li><?php endforeach; endif; else: echo "" ;endif; endif; ?>
            </ul>
        </div>
        <div class="col-md-10" style="padding-left:0px;">
            <div class="panel panel-primary margin10" style="float:left;width:100%;min-height:650px;border-color:#3C4049;">
                <div class="panel-heading" style="background-color: #3C4049;">&nbsp;</div>
                <div class="panel-body">




<link href="/Public/css/Admin/Ztree/metro.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="/Public/js/Admin/Ztree/jquery.ztree.all-3.5.min.js"></script>
<script>
    var zTree;
    var demoIframe;
    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        var addStr ="";
        if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
        addStr += "<span class='button add'    title='添加' id='addBtn_" + treeNode.tId + "'></span>";
        addStr += "<span class='button edit'   title='编辑' id='editBtn_" + treeNode.tId + "'></span>";
        addStr += "<span class='button remove' title='删除' id='removeBtn_" + treeNode.tId
        + "' title='add node' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        sObj.click(function(){
            window.location.href='<?php echo U('/Admin/Article/index');?>'+'?id='+treeNode.id;
        });
        var btn = $("#addBtn_"+treeNode.tId);
        if (btn) btn.bind("click", function(){
            window.location.href='<?php echo U('/Admin/Column/addShow');?>'+'?id='+treeNode.id;
            //alert(treeNode.id);
            /*
             var zTree = $.fn.zTree.getZTreeObj("treeDemo");
             zTree.addNodes(treeNode, {id:(1000 + newCount), pId:treeNode.id, name:"new node" + (newCount++)});
             return false;
             */
        });
        var edit_btn = $("#editBtn_"+treeNode.tId);
        if (edit_btn) edit_btn.bind("click", function(){
            window.location.href='<?php echo U('/Admin/Column/editorShow');?>'+'?id='+treeNode.id;
        });

        var remove_btn = $("#removeBtn_"+treeNode.tId);
        if (remove_btn) remove_btn.bind("click", function(){
            if(confirm("是否删除该栏目")){
                window.location.href='<?php echo U('/Admin/Column/del');?>'+'?id='+treeNode.id;
            }

        });
    };
    $(function(){
        var setting = {
            check: {
                enable: true
            },
            view: {
                addHoverDom: addHoverDom,
                removeHoverDom: removeHoverDom,
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable:true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function(treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    if (treeNode.isParent) {
                        zTree.expandNode(treeNode);
                        return false;
                    } else {
                        demoIframe.attr("src",treeNode.file + ".html");
                        return true;
                    }
                }
            }
        };
        $.ajax({
            type: 'POST',
            url:"<?php echo U('Column/index');?>",
            data: {subsection:'123'},
            success: function(data){
                zNodes = new Array();
                var obj = eval('(' + data + ')') ;
                $.each(obj,function(key,val){
                    zNodes[key] = {id:val.column_id, pId:val.column_parent, name:val.name};
                    if(val.column_open == '1') {
                        zNodes[key].open = true;
                    }else{
                        zNodes[key].open = false;
                    }
                });
                var t = $("#tree");
                t = $.fn.zTree.init(t, setting, zNodes);
                demoIframe = $("#testIframe");
                demoIframe.bind("load", loadReady);
                var zTree = $.fn.zTree.getZTreeObj("tree");
                zTree.selectNode(zTree.getNodeByParam("id", 101));
            }
        });
        $.ajax({
            type: 'POST',
            url:"<?php echo U('Column/info');?>",
            success: function(data){
                var html="";
                var obj = eval('(' + data + ')') ;
                $.each(obj,function(key,val){
                    html+=val.name+' > ';
                });
                $("#right_title").html(html);
            }
        });

    });

    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_"+treeNode.tId).unbind().remove();
        $("#removeBtn_"+treeNode.tId).unbind().remove();
        $("#editBtn_"+treeNode.tId).unbind().remove();
    };
    function loadReady() {
        var bodyH = demoIframe.contents().find("body").get(0).scrollHeight,
                htmlH = demoIframe.contents().find("html").get(0).scrollHeight,
                maxH = Math.max(bodyH, htmlH), minH = Math.min(bodyH, htmlH),
                h = demoIframe.height() >= maxH ? minH:maxH ;
        if (h < 530) h = 530;
        demoIframe.height(h);
    }


</script>

<div class="panel panel-primary margin10" style="float:left;width:20%;">
    <div class="panel-heading">
        <h3 class="panel-title wrfont16">Tree</h3>
    </div>
    <div class="panel-body">
        <ul id="tree" class="ztree"></ul>
    </div>
</div>
<div class="panel panel-primary margin10" style="float:left;width:75%">
    <div class="panel-heading">
        <h3 class="panel-title wrfont16" id="right_title"></h3>
    </div>
    <div class="panel-body">

<div >
    <a href="<?php echo U('Article/addShow');?>?column_id=<?php echo ($column_id); ?>" class="btn btn-primary" >添加文章</a>
</div >
<br>
<table id="sample-table-1" class="table table-striped table-bordered table-hover wrfont14">
    <thead>
    <tr>
        <th>序号</th>
        <th>标题</th>
        <th>创建时间</th>
        <!--  <th>图片</th>
      <th >链接</th>
        <th >图片alt</th>
        <th>状态</th>   -->
        <th width="300px">操作</th>
    </tr>
    </thead>
    <tbody>
    <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><tr>
            <td><?php echo ($val["id"]); ?></td>
            <td><?php echo ($val["name"]); ?></td>
            <td><?php echo ($val["create_time"]); ?></td>
                       <!--
            <td width="40%"><?php echo ($val["url"]); ?></td>
            <td><?php echo ($val["alt"]); ?></td>  -->
            <!--  <td style="vertical-align:middle"  width="112px">

                 <?php if($val['status'] == 1 ): ?><span class="label label-sm label-success">开启</span>
                     <?php else: ?>
                     <span class="label label-sm label-danger">关闭</span><?php endif; ?>



                <?php if($val['recommend'] == 1 ): ?><span class="label label-sm label-success">已推荐</span><?php endif; ?>

            </td>  -->
            <td style="vertical-align:middle">
               <!-- <a href="<?php echo U('Article/recommend');?>?id=<?php echo ($val["id"]); ?>" class="label label-sm label-primary">新品推荐</a>

                <?php if($val['status'] == 1 ): ?><a href="<?php echo U('Article/status');?>?id=<?php echo ($val["id"]); ?>" class="label label-sm label-danger">关闭</a>
                    <?php else: ?>
                    <a href="<?php echo U('Article/status');?>?id=<?php echo ($val["id"]); ?>" class="label label-sm label-success">开启</a><?php endif; ?>

                -->
                <a href="<?php echo U('Article/editorShow');?>?id=<?php echo ($val["id"]); ?>" class="label label-sm label-warning">编辑</a>
                <a href="<?php echo U('Article/del');?>?id=<?php echo ($val["id"]); ?>" class="label label-sm label-danger">删除</a>
            </td>
        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
    </tbody>
</table>
</div>
<div class="tk_content_page" style="width:100%"><?php echo ($page); ?></div>
</div>
</div>
</div>
</body>
</html>